using UnityEngine;
using System.Collections;

public class UpDownEnnemy : Ennemy 
{
	public AudioClip ambientClip;
	
	protected Vector3 mDirection;
	
	protected float mSpeed = 70.0f;
	
	new protected void Start()
	{
		base.Start();
		
		mDirection = new Vector3(0, 1, 0);
		
		GetComponent<EnnemySound>().SetAmbient(ambientClip, 1.0f, 1.0f, 0.2f);
	}
	
	// Update is called once per frame
	new protected void FixedUpdate () 
	{
		base.FixedUpdate();
		
		float lNextY = transform.position.y + mDirection.y * mSpeed * Time.fixedDeltaTime;
		
		if(mWalkableRect.Bottom < lNextY && mWalkableRect.Top > lNextY)
		{
			rigidbody.MovePosition(new Vector3(rigidbody.position.x - mSpeed * Time.fixedDeltaTime, lNextY, rigidbody.position.z));
		}
		else
		{
			mDirection = -mDirection;
		}
	}
	
	
}
